/*
 * SuperBlock.h
 *
 *  Created on: Mar 23, 2010
 *      Author: Lukasz Spintzyk
 */

#ifndef SUPERBLOCK_H_
#define SUPERBLOCK_H_

#ifndef PH_H_
#include "ph.h"
#endif

class Filesystem;
class SuperBlock
{
	/*SuperBlock(const SuperBlock& copy)
	{
		memcpy(this, &copy, sizeof(copy));
	};*/
	friend class Filesystem;
public:
    SuperBlock();
    virtual ~SuperBlock();

    uint32_t size();

    void read(byte* buffer);
    void write(byte* buffer);


    uint32_t getInodesPerBlock();
    uint32_t getInodeTableBlockOffset();

    bool operator==(const SuperBlock& other);

    uint32_t reservedBlocks() const;

// uint32_t d_firstInode; TODO it is necessary ?
    uint16_t d_magicNumber;
    uint32_t d_revisionNumber;
    uint32_t d_blockSize;
    uint32_t d_inodesCount;
    uint32_t d_blocksCount;

    uint32_t d_freeBlocks;
    uint32_t d_freeInodes;
    uint32_t d_firstDataBlock;
    uint32_t d_logBlockSize;
    uint32_t d_groupNum;
    uint32_t d_blocksPerGroup;
    uint32_t d_inodesPerGroup;
    time_t   d_mtime;
    time_t   d_wtime;
    uint16_t d_mntCount;
    uint16_t d_maxMntCount;
    uint16_t d_state;
    uint16_t d_errors;
    time_t   d_lastCheck;
    uint32_t d_checkInterval;
    uint32_t d_CreatorOs;
    uint16_t d_defResUID;
    uint16_t d_defResGID;

};

#endif /* SUPERBLOCK_H_ */
